package indigo.air.descriptors
{
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	
	import indigo.descriptors.IDescriptorLoader;

	public class FileDescriptorLoader implements IDescriptorLoader
	{
		public function FileDescriptorLoader()
		{
		}

		public function load(filename:String, onDescriptorLoaded:Function):void
		{
			var file:File = File.applicationDirectory.resolvePath(filename);
			var reader:FileStream = new FileStream();
			reader.open(file,FileMode.READ);
			var config:XML = XML(reader.readUTFBytes(reader.bytesAvailable));
			reader.close();
			
			onDescriptorLoaded(config);
		}
		
	}
}